const fs = require('fs')
const path = require('path')
const useRouters = function (app) {
  // 读取所有路由文件
  fs.readdirSync(__dirname).forEach(fileName => {
    if (fileName === path.parse(__filename).base) return;
    // 注册路由
    const Router = require(path.resolve(__dirname, fileName))
    app.use(Router.routes())
    app.use(Router.allowedMethods())
  })
}
module.exports = useRouters